package scuff.msg

/**
 * Message reader, which will read from source then materialize message
 * and dispatch them to the message callback.
 */
trait DispatchingMessageReader[-S, CB, +PL <: scuff.DoubleDispatch[CB]] extends MessageReader[S] {

  def callback: CB

  def materialize(source: S): PL

  def read(source: S) {
    val payload = materialize(source)
    payload.dispatch(callback)
  }

}